<!doctype html>
<html>
   <head>
	<meta charset="UTF-8">
	<title></title>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<link href="../css/mui.min.css" rel="stylesheet" />
	<style type="text/css">
		#bcid{
			width: 100%;
			height: 100%;
			position: absolute;
			background: #000000;
		}
		html, body ,div{
			height:100%;
			width: 100%;
		}
		.fbt{
			color: #0E76E1;
			width: 50%;
			background-color: #ffffff;
			float: left; 
			line-height: 44px;
			text-align: center;
		}
	</style>
   </head>
  <body>
		
	<div id="bcid">   
	     <!--盛放扫描控件的div-->  		
	</div>
		
		
	<script src="../js/mui.min.js"></script>
	<script type="text/javascript">
		mui.init();
	       scan = null;//扫描对象
		mui.plusReady(function () {
			startRecognize();
	    });
			
		function startRecognize(){
			
			 //自定义的扫描控件样式
			 var styles = {frameColor: "#29E52C",scanbarColor: "#29E52C",background: "#000"}
			 var barcode = plus.barcode.create("bcid",[plus.barcode.QR],styles);
			 plus.webview.currentWebview().append(barcode);
			 barcode.start();
			 barcode.onmarked=_onmarked;
			 barcode.onerror=()=>{
				 alert("扫描异常")
			 }
			 
		}
		const _onmarked = function(type, code, file){
			switch(type){
				case plus.barcode.QR:
					console.log(code)
					rosolverScanResultWithQR(code);
					break;
			}
		}
		function rosolverScanResultWithQR(code){
			const index = code.indexOf(":");
			var type,text;
			if(index!=-1){
				type = code.substring(0,index);
				text = code.substr(index+1);
			}
			
			if(type === "USER"){
				mui.openWindow({
					url:"sacn-code-friends-info.html",
					id:"sacn-code-friends-info.html",
					styles:{
						
					},
					show:{
						autoShow:true,
						aniShow:"slide-in-right",
						duration:300
					},
					extras:{
						_ext_user_id:text,
						bindType:2
					},
					waiting:{
						 autoShow: true, //自动显示等待框，默认为true  
						 title: '正在加载...', //等待对话框上显示的提示内容  
					}
				})
				setTimeout(()=>{
					plus.webview.currentWebview().close();
				},350)
			}
		}
		</script>
	</body>
</html>